package com.heima.wemedia.controller.v1;


import com.heima.model.admin.dtos.AdChannelDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import org.springframework.web.bind.annotation.*;


/**
 * @Description TODO
 * @Author bo.li
 * @Date 2022/11/10 10:42
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {




    @Autowired
    private WmChannelService wmchannelService;

    @GetMapping("/channels")
    public ResponseResult list(){
        return ResponseResult.okResult(wmchannelService.list());
    }
    @PostMapping("/list") //分页查询
    public ResponseResult findAll(@RequestBody AdChannelDto dto) {
        return wmchannelService.findAll(dto);
    }
    @PostMapping("/update")
    public ResponseResult updateChannel(@RequestBody WmChannel wmChannel){
        return wmchannelService.updateChannel(wmChannel);
    }
    @PostMapping("/save")
    public ResponseResult saveChannel(@RequestBody WmChannel wmChannel){
        return wmchannelService.saveChannel(wmChannel);
    }
    @GetMapping("/del/{id}")
    public ResponseResult deleteChannel(@PathVariable("id") Integer id ){
        return wmchannelService.deleteChannel(id);
    }

    }

